<form method="post" action="#">
    <div class="row">
        <div class="span12">
            <h4>Form Perusahaan</h4><br/><br/>
            <div class="row">
                <div class="span2">Nama</div>
                <input type="text" name="txtName" class="span3" id="txtName" value="<?= @$low->company_name ?>"/>
                <font class="strerr"><?= @$err->company_name ?></font>
            </div>
            <div class="row">
                <div class="span2">Province</div>
                <select name="ddPropinsi" id="ddPropinsi">
                    <option value="">Select</option>
                    <? foreach (getPropinsi() as $k => $v) { ?>
                        <option value="<?= $v->province_id ?>"<?= @$low->province_id == $v->province_id ? ' selected="selected"' : "" ?>><?= $v->province_nama ?></option>
                    <? } ?>
                </select>
                <font class="strerr"><?= @$err->homeprovinceid ?></font>
            </div>
            <div class="row">
                <div class="span2">Kota</div>
                <select name="ddKota" id="ddKota">
                    <? foreach (getKabupaten(@$low->province_id) as $k => $v) { ?>
                        <option value="<?= $v->city_id ?>"<?= @$low->city_id == $v->city_id ? ' selected="selected"' : "" ?>><?= $v->city_nama ?></option>
                    <? } ?>
                </select>
                <font class="strerr"><?= @$err->homecityid ?></font>
            </div>
            <div class="row">
                <div class="span2">Alamat</div>
                <textarea name="txtAddr" class="span3" id="txtAddr"><?= @$low->company_address ?></textarea>
                <font class="strerr"><?= @$err->company_address ?></font>
            </div>
            <div class="row">
                <div class="span2">Deskripsi</div>
                <textarea name="txtDescr" class="span3" id="txtDescr"><?= @$low->company_description ?></textarea>
                <font class="strerr"><?= @$err->company_description ?></font>
            </div>
            <input type="submit" class="btn btn-primary" value="Simpan"/>
            <a class="btn btn-dark" href="<?= base_url() ?>company">Batal</a>
        </div>
    </div>
</form>
<script>
    $('#ddPropinsi').change(function(){
        $('#ddKota').empty();
        $.post('<?= base_url() . "region/kabupaten" ?>', {id:$('#ddPropinsi').val()}, function(data) {
            if(data){
                var datajs = $.parseJSON(data);
                $('<option value="">Select</option>').appendTo("#ddKota");
                $.each(datajs, function(key, value){
                    $("<option value='"+value.city_id+"'>"+value.city_nama+"</option>").appendTo("#ddKota");
                });
            }
        });
    });
</script>